package dd.control;


import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

import dd.model.Event;
import dd.model.Model;

import xml.Message;

public class TurnResponseController {
	/**
	 * call when get TurnResponse
	 * this response tell the player that it is his turn to draw an edge in roundRobin type
	 * the player get the ability to draw an edge 
	 */
	
	public void process(Message response){
		Model model = Model.getInstance();
		Event e = model.getEvent();
		Node update = response.contents.getFirstChild();
		NamedNodeMap map = update.getAttributes();
		String iscomplete = map.getNamedItem("completed").getNodeValue();
		//if all the edges have been added
		if(iscomplete.equals("true")){
			e.setcomplete(true);
		}
		else{ 
			e.setcomplete(false);
			e.setIsYourTurn(true);
			model.getaef().repaint();
		}
	}
}
